class CreateJobs < ActiveRecord::Migration
  def self.up
    create_table :jobs do |t|
      t.column :institution, :string
      t.column :position, :string
      t.column :department, :string
      t.column :start_date, :date
      t.column :end_date, :date
      t.column :city, :string
      t.column :state, :string
      t.column :user_id, :integer
    end

    add_index :jobs, :user_id
    add_index :jobs, :institution
    add_index :jobs, :position
    add_index :jobs, :department

    foreign_key :jobs, :user_id, :users

    remove_column :users, :position
    remove_column :users, :university
    remove_column :users, :department
    remove_column :users, :affiliations
    remove_column :users, :birth_date
  end

  def self.down
    drop_table :jobs
    add_column :users, :position, :string
    add_column :users, :university, :string
    add_column :users, :department, :string
    add_column :users, :affiliations, :string
    add_column :users, :birth_date, :string
  end
end
